package com.xbang.attendance.web.action.system.wtime;

import java.util.ArrayList;
import java.util.List;

import com.demo2do.lighturl.annotation.Action;
import com.xbang.attendance.entity.department.Department;
import com.xbang.attendance.entity.wtime.Wtime;

import com.xbang.attendance.service.SystemService;
import com.xbang.attendance.utils.MD5;
import com.xbang.core.struts.support.SearchActionSupport;

public class WimeManager extends SearchActionSupport {
	private Integer id;
	private Wtime user;
	private SystemService systemService;
	private List<Department> departmentList=new ArrayList<Department>();
	public void setSystemService(SystemService systemService) {
		this.systemService = systemService;
	}
	public Wtime getUser() {
		return user;
	}
	public void setUser(Wtime user) {
		this.user = user;
	}
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Action("/system/wtime/${id}/edit")
	public String detail() throws Exception {
		user=new Wtime();
		if (id != null) {
			departmentList=systemService.getObjects(Department.class);
			user = (Wtime) systemService.getObject(Wtime.class, id);
		}
		return "detail";
	}
	public List<Department> getDepartmentList() {
		return departmentList;
	}
 

	public void setDepartmentList(List<Department> departmentList) {
		this.departmentList = departmentList;
	}


	@Action("/system/wtime/add")
	public String add() throws Exception {
		user=new Wtime();
		departmentList=systemService.getObjects(Department.class);
		return "detail";
	}
	@Override
	public void resetCustomerSearchCriteria() {
		// TODO Auto-generated method stub

	}
	/*private String departmentId(String name){
		
		return null;
	}*/
	@Action("/system/wtime/save")
	public String save() throws Exception {
		if (null !=user) {
			int did=Integer.parseInt(user.getDepartment());
			user.setDepartment(did+"");
			systemService.save(user);
			}
		
		return "r:/system/wtime/list";
	}
	
	public SystemService getSystemService() {
		return systemService;
	}


	@Action("/system/wtime/update")
	public String update() throws Exception {
		systemService.update(user);		
		return "r:/system/wtime/list";
	}
}

